<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" size="tiny" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
		<div class="bt">新增支出费用登记</div>
		<el-form label-width="100px" class="form">
		  <el-form-item label="费用类型">
 				<!--<el-input v-model="vfylx"  placeholder="请输入费用类型" class="select-block"></el-input>-->
                <el-select v-model="vfylx" placeholder="请选择费用类型" class="select-block">
                      <el-option :label="v.fylxmc" :value="v.fylx" v-for="v in comboxlist"></el-option>
                </el-select>
                <p style="color: red; width: 80%; text-align: right;">注 : 可以在基础设置模块中学校参数功能中添加</p>
			</div>
 			</el-form-item>

		<el-form-item label="支出时间">
			<el-date-picker   v-model="vzcsj"  placeholder="选择日期"  class="select-block"> </el-date-picker>
 			</el-form-item>
 			
 			<el-form-item label="支出金额">
 				<el-input v-model="vzcje" type="number"  placeholder="请输入支出金额" class="select-block"></el-input>
 			</el-form-item>

		<el-form-item label="支出原因">
 				<el-input v-model="vzcyy"  type="textarea" :rows="4" placeholder="请输入支出原因" class="select-block"></el-input>
 			</el-form-item>

		</el-form>
		<div class="an" style="text-align: center;">
		<el-button type="primary" class="submit" @click="submit">添加</el-button>
		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
		</div>
	</el-dialog>
</template>
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vfylx: '',
				vzcsj: '',
				vzcje: '',
				vzcyy:'',
				comboxlist:[],
			}
		},
		created () {
			    this.getfylxcomlist();
		},
		methods: {
		getfylxcomlist() {
        var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                    xxid: logininfo.xxid,
                    yhid:logininfo.id
               })
             //执行
                 this.axios.post(this.$store.state.api + 'xxcode/getcwfl',  params2 )
                 .then(res => {
//               console.log('11111',res)
                  let data = res.data.data;
                  let list = data.list;
                  this.comboxlist = list;
                  this.searchLoading = false;
                 }).catch(res => {
                  this.searchLoading = false;
				})
          },
			submit() {
				//检测
				 this.$store.state.loading = true;
			    if(!this.vfylx) {
					this.$message.warning('请填写费用类型');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vzcsj) {
					this.$message.warning('请选择支出时间');
					this.$store.state.loading = false;
					return;
				}
				else if(!this.vzcje) {
					this.$message.warning('请输入支出金额');
					this.$store.state.loading = false;
					return;
				}
				var logininfo = JSON.parse(localStorage.logininfo);
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vzcsj[0]));
				var params3 = qs.stringify({
	    			fylx: this.vfylx,
	    			zcsj:this.vzcsj,
	    			zcje:this.vzcje,
	    			zcyy:this.vzcyy,
					yhid: logininfo.id,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'cwfyzc/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add1', cancel: false });
							this.$store.state.loading = false;
						} else {
						this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add1', cancel: true })
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.form {
		text-align: center;
		margin-top:20px;
	}
	 .select-block {
 		display: block;
 		width: 85%;
 	}
		.input {
			display: inline-block;
		}
		.submit {
			width: 120px;
		}
	}
</style>
